Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: use the config binding to carry --no-browser-globals #26228

Closed
wants to merge 1 commit into from

Conversation

joyeecheung
Copy link
Member

Instead of setting it in the process object, since this is
a configure-time option. Also added a shim that can be
deprecated and removed some time later.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Feb 21, 2019
@danbev
Copy link
Contributor

danbev commented Feb 21, 2019

// it from the process. We may consider exposing it properly in
// process.features.
const { noBrowserGlobals } = internalBinding('config');
process._noBrowserGlobals = noBrowserGlobals;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behavior to the former.

Before, this variable was only set in case it was true. Now it's set unconditionally.
It is now also set as a regular property and not only as read-only.

@BridgeAR
Copy link
Member

BridgeAR commented Mar 5, 2019

Ping @joyeecheung

Instead of setting it in the process object, since this is
a configure-time option. Also added a shim that can be
deprecated and removed some time later.
@joyeecheung
Copy link
Member Author

joyeecheung commented Mar 6, 2019

@BridgeAR Thanks for review, updated.

CI: https://ci.nodejs.org/job/node-test-pull-request/21255/ ✔️

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 6, 2019
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Mar 6, 2019
Instead of setting it in the process object, since this is
a configure-time option. Also added a shim that can be
deprecated and removed some time later.

PR-URL: nodejs#26228
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@BridgeAR
Copy link
Member

BridgeAR commented Mar 6, 2019

Landed in 03c71a9 🎉

@BridgeAR BridgeAR closed this Mar 6, 2019
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Mar 12, 2019
Instead of setting it in the process object, since this is
a configure-time option. Also added a shim that can be
deprecated and removed some time later.

PR-URL: nodejs#26228
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
BridgeAR pushed a commit that referenced this pull request Mar 14, 2019
Instead of setting it in the process object, since this is
a configure-time option. Also added a shim that can be
deprecated and removed some time later.

PR-URL: #26228
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@zcbenz
Copy link
Contributor

zcbenz commented Mar 29, 2019

This is actually causing some problems in Electron.

We load Node in 2 different environments:

  1. Independent mode like the upstream one, which installs all browser globals
  2. Browser mode which runs together with DOM and does not install browser globals.

By turning this config into compile-time only, we are not able to switch modes at runtime.

/cc @nitsakh @codebytere

zcbenz added a commit to electron/node that referenced this pull request Mar 29, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
@joyeecheung
Copy link
Member Author

@zcbenz Hi,

I am pretty sure process.noBrowserGlobals was already processed pretty early during to bootstrap so after that it was not possible to change the browser globals at run time anyway? --no-browser-globals was already a build time flag before this patch, it was not a valid CLI option for node. This patch just moves process.noBrowserGlobals to process.binding('config').noBrowserGlobals and shim it later so that it would be easier to just remove process.noBrowserGlobals some time.

I think we can make the installation dynamic at run time, though process.noBrowserGlobals is not an ideal place to do that. For example, we can make process.features.browserGlobals an accessor property and toggle the globals dynamically

@zcbenz
Copy link
Contributor

zcbenz commented Mar 30, 2019

@joyeecheung We hijacked the bootstrap script to install some Electron specific things to Node. Having a dynamic flag would be great.

@joyeecheung
Copy link
Member Author

@zcbenz If you just hijack the property passed into bootstrap script and only need it once, maybe the easiest workaround is to hijack process.binding('config') (in src/node_config.cc) instead.

zcbenz added a commit to electron/node that referenced this pull request Apr 10, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
zcbenz added a commit to electron/node that referenced this pull request Apr 10, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
zcbenz added a commit to electron/node that referenced this pull request Apr 10, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
zcbenz added a commit to electron/node that referenced this pull request Apr 10, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
zcbenz added a commit to electron/node that referenced this pull request Apr 10, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
zcbenz added a commit to electron/node that referenced this pull request Apr 11, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
nitsakh pushed a commit to electron/node that referenced this pull request Apr 11, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
nitsakh pushed a commit to electron/node that referenced this pull request Apr 11, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
nitsakh pushed a commit to electron/node that referenced this pull request Apr 11, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
nitsakh pushed a commit to electron/node that referenced this pull request Apr 11, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
zcbenz added a commit to electron/node that referenced this pull request Apr 16, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
zcbenz added a commit to electron/node that referenced this pull request Apr 16, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
codebytere pushed a commit to electron/node that referenced this pull request Jun 20, 2019
This is a temporary hack in responding to Node's change:
nodejs/node#26228

We need to figure out a better solution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants